package chess;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



/**
 *
 * @author houfukude
 */
import   java.awt.*;
import java.awt.event.*;
import javax.swing.*;
                                                           
  public class chess extends JFrame{     //添加棋盘的窗口。
      ChessPad chesspad = new ChessPad(); //Chess extends panel
      chess(){
          
          try {

            go2();
            } catch (Exception ex) {
           // Logger.getLogger(chess.class.getName()).log(Level.SEVERE, null, ex);
            }
          setSize(600,600);
          setVisible(true);
          setLayout(new FlowLayout());
          
          
        
            /*addWindowListener(new WindowAdapter()
            {
            @Override
            public void windowClosing(WindowEvent e){
            System.exit(0);
            }
            }
            );*/
            //用JFrame.EXIT_ON_CLOSE代替了

          Label label = new Label("单击下棋子，双击吃棋子，右击棋子悔棋",Label.CENTER);
          add(label);
          label.setBounds(70,55,440,26);
          label.setBackground(Color.orange);
          add(chesspad);
          chesspad.setBounds(70,90,440,440);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        
      }

       public void go2() throws Exception{
        //menubar
        JMenuBar jmb = new JMenuBar();
        this.setJMenuBar(jmb);
        //file
        MenuAction themenu = new MenuAction();
        JMenu jm1 = new JMenu("File(F)");
        jm1.setMnemonic(KeyEvent.VK_F);
        jmb.add(jm1);
        JMenuItem jmi1;
        //file menu
        jmi1 = new JMenuItem("开始(S)");
        jmi1.setMnemonic(KeyEvent.VK_S);
        jmi1.setActionCommand("Start");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);

        //jmi1 = new JMenuItem("Cancel(C)");
        //jmi1.setMnemonic(KeyEvent.VK_C);
        //jmi1.setActionCommand("Cancel");
        //jmi1.addActionListener(themenu);
        //jm1.add(jmi1);

        jm1.add(new JSeparator());

        jmi1 = new JMenuItem("Exit(E)");
        jmi1.setMnemonic(KeyEvent.VK_E);
        jmi1.setActionCommand("Exit");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);

        //Option
        jm1 = new JMenu("Option(O)");
        jm1.setMnemonic(KeyEvent.VK_O);
        jmb.add(jm1);
        //color menu
        jmi1 = new JMenuItem("黑子先手");
        jmi1.setActionCommand("Black");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);
        //切换到日期计算
        jmi1 = new JMenuItem("白子先手");
        jmi1.setActionCommand("White");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);


        //Help
        jm1 = new JMenu("Help");
        jm1.setMnemonic(KeyEvent.VK_H);
        jmb.add(jm1);
        //option menu
        jmi1 = new JMenuItem("Help website");
        jmi1.setActionCommand("Help");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);

        //about
        jm1 = new JMenu("About");
        jm1.setMnemonic(KeyEvent.VK_A);
        jmb.add(jm1);
        //option menu
        jmi1 = new JMenuItem("About the author");
        jmi1.setActionCommand("About");
        jmi1.addActionListener(themenu);
        jm1.add(jmi1);

    }
      
  }
